package com.huluobo.a2308douyindemo.adapter

import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.huluobo.a2308douyindemo.R
import com.huluobo.a2308douyindemo.bean.HomeGoodsBean

/**
 *  Created by LC on 2025/11/6.
 *  首页一级列表adapter
 */
class HomeParentAdapter : BaseQuickAdapter<HomeGoodsBean, BaseViewHolder>(R.layout.item_home_parent) {
    override fun convert(holder: BaseViewHolder, item: HomeGoodsBean) {
        holder.setText(R.id.item_home_parent_tv, item.name)
        val rv = holder.getView<RecyclerView>(R.id.item_home_rv)
        rv.layoutManager = GridLayoutManager(context, 2)
        val childAdapter = HomeChildAdapter()
        rv.adapter = childAdapter
        childAdapter.data.addAll(item.mallGoodsInfoPageResponseList)
        childAdapter.notifyDataSetChanged()
    }
}